package com.demo.config;

import com.demo.Interceptor.CancelInterceptor;
import com.demo.Interceptor.CheckLoginInterceptor;
import com.demo.Interceptor.MyInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Slf4j
@Configuration
public class WebInterceptorConfig extends WebMvcConfigurationSupport {
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**","resources/static/**","/public/**")
                .addResourceLocations("classpath:/resources/static/", "classpath:/public/");
        super.addResourceHandlers(registry);
    }



    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/","/html","/index.html")
                .excludePathPatterns("/resources/**","/public/**","/static/**");
//        registry.addInterceptor(new CheckLoginInterceptor()).addPathPatterns("/**");
//        registry.addInterceptor(new CancelInterceptor()).addPathPatterns("/**");
        super.addInterceptors(registry);
    }

}